package com.seafood.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 温度监控日志实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "temperature_logs")
public class TemperatureLog extends BaseEntity {
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cold_chain_record_id", nullable = false)
    private ColdChainRecord coldChainRecord;
    
    @NotNull(message = "记录时间不能为空")
    @Column(name = "record_time", nullable = false)
    private LocalDateTime recordTime;
    
    @NotNull(message = "温度不能为空")
    @DecimalMin(value = "-50.0", message = "温度不能低于-50°C")
    @DecimalMax(value = "50.0", message = "温度不能高于50°C")
    @Column(name = "temperature", nullable = false, precision = 5, scale = 2)
    private BigDecimal temperature;
    
    @DecimalMin(value = "0.0", message = "湿度不能小于0%")
    @DecimalMax(value = "100.0", message = "湿度不能超过100%")
    @Column(name = "humidity", precision = 5, scale = 2)
    private BigDecimal humidity;
    
    @Column(name = "location", length = 500)
    private String location;
    
    @Column(name = "gps_coordinates", length = 100)
    private String gpsCoordinates;
    
    @Column(name = "device_id", length = 100)
    private String deviceId;
    
    @Column(name = "device_online")
    private Boolean deviceOnline = true;
    
    @Column(name = "battery_level", precision = 5, scale = 2)
    private BigDecimal batteryLevel;
    
    @Column(name = "signal_strength")
    private Integer signalStrength;
    
    @Column(name = "is_abnormal")
    private Boolean isAbnormal = false;
    
    @Column(name = "abnormal_reason", length = 500)
    private String abnormalReason;
}